/*******************************************************************************
Replication Materials for Blau, Kahn, Brummund, Cook, and Larson-Koester "Is 
There Still Son Preference in the United States?"

Table R2

Date Modified: 10/19/2019

*******************************************************************************/




*-------------------------------------------------------------------------------
                                   *LOAD DATA
*-------------------------------------------------------------------------------
use "$acs\acs_data", clear


*-------------------------------------------------------------------------------
                               *RESTRICT SAMPLE
*-------------------------------------------------------------------------------
keep if nonusbirth == 0 & multi_sample != 1 & mult == 0 & oldc <=12 & ///
	inrange(age,18,40)==1 & nchild18>=1 & nonrkids == 0 & nonusbirth == 0 ///
	& sfrelate == 0 & father_sample != 1 & female == 1 & foster_hh == 0
drop if citizen == 1 | marst == 5

*-------------------------------------------------------------------------------
                             *LABEL VARS
*-------------------------------------------------------------------------------

*Label Variables
label var igenfert "Total Fertility"
label var ligengdp "Log of GDP"
label var igenscore "Equity Index"
label var chld1 "First Child Girl"
label var igenlfp "Labor Force Part."
label var igensr "Sex Ratio at Birth"

label var girl_lfp "Girl*Labor Force Part."
label var girl_sr "Girl*Sex Ratio at Birth"
label var girl_ggi "Girl*Equity Index"




*-------------------------------------------------------------------------------
                       *REGRESSIONS, PROB LIVING WITHOUT A FATHER
*-------------------------------------------------------------------------------	
local wgt "hhwtnorm"	
local controls "lths scol cold" //leave out: hsdi
local controls "`controls' i.genrace i.region i.year age age2 age3 `allvars'"
local controls "`controls' yrsusa1 yrsusa2"

// EQUITY
reg femhdalt `controls' igenfert ligengdp igenscore chld1 girl_ggi [aw=`wgt'],  cluster(bpldc)
sum femhdalt if igenscore != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R2", replace excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenscore chld1 girl_ggi) ctitle(No Dad) label nocons nor2 ///
	title("Table R2: Table 3 for All Women")

// LFPR
reg femhdalt `controls' igenfert ligengdp igenlfp chld1 girl_lfp [aw=`wgt'],  cluster(bpldc)
sum femhdalt if igenlfp != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R2", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp chld1 girl_lfp) ctitle(No Dad) label nocons nor2

// LFPR & SEX RATIO AT BIRTH
reg femhdalt `controls' igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr [aw=`wgt'],  cluster(bpldc)
sum femhdalt if igenlfp != . & igensr != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R2", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr) ctitle(No Dad) label nocons nor2

*-------------------------------------------------------------------------------
                              *REGRESSIONS, FERTILITY
*-------------------------------------------------------------------------------	
local wgt "hhwtnorm"	
local controls "lths scol cold" //leave out: hsdi
local controls "`controls' i.genrace i.region i.year age age2 age3 `allvars'"
local controls "`controls' yrsusa1 yrsusa2"

// SAMPLE
*keep if marst == 1

// EQUITY
reg nchild `controls' igenfert ligengdp igenscore chld1 girl_ggi [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenscore != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R2", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenscore chld1 girl_ggi) ctitle(Fertility) label nocons nor2

// LFPR
reg nchild `controls' igenfert ligengdp igenlfp chld1 girl_lfp [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenlfp != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R2", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp chld1 girl_lfp) ctitle(Fertility) label nocons nor2

// LFPR & SEX RATIO AT BIRTH
reg nchild `controls' igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenlfp != . & igensr != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R2", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr) ctitle(Fertility) label nocons nor2 sortvar(igenfert ligengdp igenlfp igensr igenscore chld1 girl_lfp girl_sr girl_ggi)
 
